package com.qf.controller;

import com.qf.annotation.IsLogin;
import com.qf.aop.UserLocal;
import com.qf.entity.*;
import com.qf.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("orders")
public class OrdersController {
    @Autowired
    private IOrderService iOrderService;

    @RequestMapping("/toOrderEdit")
    @IsLogin(mustLogin = true)
    public R toOrderEdit(String rid){
        User user = UserLocal.getUser();
        System.out.println("接收到下单请求: " + rid + "下单的用户:" + user);
        return new R();
    }

    @RequestMapping("/getPrices")
    public R getPrices(PricesParams pricesParams){
        PricesResult prices = iOrderService.getPrices(pricesParams);
        return new R().setData(prices);
    }

    @RequestMapping("/createOrders")
    @IsLogin(mustLogin = true)
    public R createOrders(Orders orders,PricesParams pricesParams){
        System.out.println("接收到下单请求："+ orders);
        String orderid = iOrderService.createOrders(orders, pricesParams);
        return new R().setData(orderid);
    }
}
